#include<iostream>
#include<map>
using namespace std;
map<int,int> mp;
int main(){
	int n,x,ans1,ans2=0;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> x;
		mp[x]++;
	}
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
		if(it->second>=ans2){
			ans2 = it->second;
			ans1 = it->first;
		}
	}
	cout << ans1 << " " << ans2 << endl;
	return 0;
}
